<template>
  <div class="f-table">
    <el-table ref="fTable" v-bind="tableConfig" :data="data" v-on="tableEvents">
      <!-- TODO：append render function components -->
      <el-table-column v-for="(item, index) of columns" :key="item.prop || index" v-bind="item" :resizable="false" />
      <template #empty>
        <el-empty description="暂无数据哦~" />
      </template>
    </el-table>
  </div>
</template>

<script setup lang="jsx">
import { onMounted, ref } from 'vue'

const fTable = ref()
const tableConfig = {
  stripe: true,
  border: true,
  size: 'default',
  'highlight-current-row': true,
  'current-row-key': 'current-row',
  'row-key': (row) => row.prop
}
const tableEvents = {}
const columns = ref([
  {
    type: 'selection',
    width: 'auto',
    align: 'center',
    'reserve-selection': true,
    selectable: (row, index) => {
      return row.name === 'Tom' && index % 2 === 0
    }
  },
  {
    type: 'index',
    align: 'center',
    label: '序号',
    width: '60'
  },
  {
    label: '日期',
    prop: 'date',
    width: '180'
  },
  {
    label: '名称',
    prop: 'name',
    width: '180'
  },
  {
    label: '地址',
    prop: 'address',
    width: 'auto'
  },
  {
    width: '180',
    label: '操作'
  }
])
const data = ref([
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles'
  }
])

onMounted(() => {})
</script>

<style scoped>
.f-table {
  box-sizing: border-box;
  padding: 14px;
  background-color: #ffffff;
}
</style>
